package com.scedu.spring5.dao;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@Service
public class AccountDaoImpl implements AccountDao {
    @Autowired
    JdbcTemplate jdbcTemplate;

   //多钱
    @Override
    public void addMoney() {
        String sql="update t_account set money=money+? where username=?";
        Object[] args={ 100, "marry"};
        int update = jdbcTemplate.update(sql,args );
        System.out.println(update);

    }
    //lucky转账给marry
    //少钱
    @Override
    public void reduceMoney() {
        String sql="update t_account set money=money-? where username=?";
        //2.可变参数 数组
        Object[] args={ 100, "lucy"};
        int update = jdbcTemplate.update(sql,args );
        System.out.println(update);

    }
}
